package com.boom.monitor.service;

import com.boom.common.utils.DateUtils;
import com.boom.common.utils.SecurityUtils;
import com.boom.common.utils.uuid.IdUtils;
import com.boom.monitor.domain.MonitorTopology;
import com.boom.monitor.mapper.MonitorTopologyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 拓扑管理Service业务层处理
 *
 * @author boom
 * @date 2021-06-15
 */
@Service
public class MonitorTopologyService {

	@Autowired
	private MonitorTopologyMapper monitorTopologyMapper;

	/**
	 * 查询拓扑管理
	 *
	 * @param id 拓扑管理ID
	 * @return 拓扑管理
	 */
	public MonitorTopology selectMonitorTopologyById(String id) {
		return monitorTopologyMapper.selectMonitorTopologyById(id);
	}

	/**
	 * 查询拓扑管理列表
	 *
	 * @param monitorTopology 拓扑管理
	 * @return 拓扑管理
	 */
	public List<MonitorTopology> selectMonitorTopologyList(MonitorTopology monitorTopology) {
		return monitorTopologyMapper.selectMonitorTopologyList(monitorTopology);
	}

	/**
	 * 新增拓扑管理
	 *
	 * @param monitorTopology 拓扑管理
	 * @return 结果
	 */
	public int insertMonitorTopology(MonitorTopology monitorTopology) {
		monitorTopology.setCreateTime(DateUtils.getNowDate());
		monitorTopology.setId(IdUtils.simpleUUID());
		monitorTopology.setCreateBy(SecurityUtils.getUsername());
		monitorTopology.setUpdateTime(DateUtils.getNowDate());
		monitorTopology.setUpdateBy(SecurityUtils.getUsername());
		return monitorTopologyMapper.insertMonitorTopology(monitorTopology);
	}

	/**
	 * 修改拓扑管理
	 *
	 * @param monitorTopology 拓扑管理
	 * @return 结果
	 */
	public int updateMonitorTopology(MonitorTopology monitorTopology) {
		monitorTopology.setUpdateTime(DateUtils.getNowDate());
		monitorTopology.setUpdateBy(SecurityUtils.getUsername());
		return monitorTopologyMapper.updateMonitorTopology(monitorTopology);
	}

	/**
	 * 批量删除拓扑管理
	 *
	 * @param ids 需要删除的拓扑管理ID
	 * @return 结果
	 */
	public int deleteMonitorTopologyByIds(String[] ids) {
		return monitorTopologyMapper.deleteMonitorTopologyByIds(ids);
	}

	/**
	 * 删除拓扑管理信息
	 *
	 * @param id 拓扑管理ID
	 * @return 结果
	 */
	public int deleteMonitorTopologyById(String id) {
		return monitorTopologyMapper.deleteMonitorTopologyById(id);
	}
}
